"""Pydantic schemas for exploration feature operations."""

from __future__ import annotations

from datetime import datetime
from typing import List, Optional, Dict, Any

from pydantic import BaseModel, Field


class ExplorationStart(BaseModel):
    """Schema for starting exploration."""
    book_id: int
    theme: Optional[str] = None
    difficulty: str = Field(default="中等")


class ExplorationStep(BaseModel):
    """Schema for exploration step."""
    session_id: int
    choice: str = Field(min_length=1, max_length=500)


class ExplorationSessionOut(BaseModel):
    """Schema for exploration session output."""
    id: int
    book_id: int
    theme: Optional[str]
    difficulty: str
    current_step: int
    progress: float
    is_completed: bool
    created_at: datetime
    updated_at: datetime

    class Config:
        from_attributes = True


class ExplorationSessionDetail(ExplorationSessionOut):
    """Schema for detailed exploration session."""
    session_data: Optional[Dict[str, Any]]


class ExplorationProgress(BaseModel):
    """Schema for exploration progress."""
    session_id: int
    current_step: int
    total_steps: int
    progress: float
    next_action: Optional[str] = None


class ExplorationRecommendation(BaseModel):
    """Schema for exploration recommendations."""
    theme: str
    books: List[Dict[str, Any]]
    estimated_time: Optional[int] = None  # minutes
    difficulty: str


class ExplorationStepResponse(BaseModel):
    """Schema for exploration step response."""
    step_content: str
    choices: List[str]
    progress: float
    is_final: bool = False